package com.kgc.web;

import com.kgc.dao.homeDao;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;

@WebServlet(name = "homeServlet", value = "/homeServlet")
public class homeServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String opt = request.getParameter("opt");
        System.out.println("opt = " + opt);
        if ("total".equals(opt)) {
            Integer uc1 = new homeDao().userCount();
            request.setAttribute("uc1",uc1 );
            Integer uc2 = new homeDao().gonggaoCount();
            request.setAttribute("uc2",uc2 );
            Integer uc3 = new homeDao().tousuCount();
            request.setAttribute("uc3",uc3 );
            Integer uc4 = new homeDao().repairCount();
            request.setAttribute("uc4",uc4 );
            Integer uc5 = new homeDao().roomCount();
            request.setAttribute("uc5",uc5 );
            Integer uc6 = new homeDao().carCount();
            request.setAttribute("uc6",uc6 );
            Integer uc7 = new homeDao().userPaymentCount();
            request.setAttribute("uc7",uc7 );
            Integer uc8 = new homeDao().roomCountHas();
            request.setAttribute("uc8",uc8 );
            Integer uc9 = new homeDao().carCountHas();
            request.setAttribute("uc9",uc9 );
            Integer uc10 = new homeDao().userPaymentCountHas();
            request.setAttribute("uc10",uc10 );

            request.getRequestDispatcher("/page/admin/console.jsp").forward(request, response);

        }

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}
